package ink.tiptop.learn.pojo;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * @author zjf
 * @date 2020-08-14 20:51:52
 */
public class CommonResult {
    public static CommonResult SUCCESS = new CommonResult("000000", "成功");
    public static CommonResult FAILED = new CommonResult("999999", "失败");
    @JsonProperty("BODY")
    @Accessors(chain = true)
    @Getter
    @Setter
    private Object body;
    @JsonProperty("CODE")
    private final String code;
    @JsonProperty("MSG")
    private final String msg;

    private CommonResult(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static CommonResult success(Object obj) {
        return SUCCESS.setBody(obj);
    }
}